package org.helgoboss.single_source_builder_main

class Artifact (
    val groupId: String, 
    val artifactId: String, 
    val version: String,
    val name: Option[String] = None,
    val packaging: Option[String] = None
) { 
    def groupIdXml = {
        <groupId>{groupId}</groupId>
    }
    
    def artifactIdXml = {
        <artifactId>{artifactId}</artifactId>
    }
    
    def versionXml = {
        <version>{version}</version>
    }
    
    def nameXml = {
        if (name.isDefined) {
            <name>${name}</name>
        } else {
            null
        }
    }
    
    def packagingXml = {
        if (packaging.isDefined) {
            <packaging>${packaging}</packaging>
        } else {
            null
        }
    }
    
    def typeXml = {
        if (packaging.isDefined) {
            <type>${packaging}</type>
        } else {
            null
        }
    }
    
    def mkString(separator: String) = {
        groupId + separator + artifactId + separator + version
    }
}